/** /////////////////////////////////////////////////////////////////////////////////
 * @author	Jaeger, Mathias
 * @function erstelleComposer() dient dazu die Shader für das Postprocessing 
 * 			zu erstellen und dem laneAssist.composer hinzuzufuegen. 
 /////////////////////////////////////////////////////////////////////////////////*/

function erstelleComposer() {
	// postprocessing
	var depthMaterial;
	var depthTarget;

	var pixelFormat = 1;
	if (window.devicePixelRatio !== undefined) {
		pixelFormat = window.devicePixelRatio;
	}

	var renderPass = new THREE.RenderPass(szene, kameraPerspektiv);
	var effectcopy = new THREE.ShaderPass(THREE.CopyShader);
	effectcopy.renderToScreen = true;
	
	 var effectvignette = new THREE.ShaderPass(THREE.VignetteShader);
	 effectvignette.uniforms.darkness.value = 0;
	 effectvignette.uniforms.offset.value = 1;
	
	 var fxaa = new THREE.ShaderPass(THREE.FXAAShader);
	 fxaa.uniforms['resolution'].value.set(1 / (laneAssist.fensterBreite * pixelFormat), 1 / (laneAssist.fensterHoehe * pixelFormat));
	
	 // var focusShader = new THREE.ShaderPass(THREE.FocusShader);
	 // focusShader.enabled = true;
	 // focusShader.uniforms.screenWidth.value = laneAssist.fensterBreite;
	 // focusShader.uniforms.screenHeight.value = laneAssist.fensterBreite;
	 // focusShader.uniforms.waveFactor.value = 0.000005;
	 // focusShader.uniforms.sampleDistance.value = 0.5;
	 // focusShader.renderToScreen = false;


	 // depth for SSAO
	 var depthShader = THREE.ShaderLib["depthRGBA"];
	 var depthUniforms = THREE.UniformsUtils.clone(depthShader.uniforms);

	 depthMaterial = new THREE.ShaderMaterial({
	 fragmentShader : depthShader.fragmentShader,
	 vertexShader : depthShader.vertexShader,
	 uniforms : depthUniforms
	 });
	 depthMaterial.blending = THREE.NoBlending;

	 depthTarget = new THREE.WebGLRenderTarget(laneAssist.fensterBreite, laneAssist.fensterHoehe, {
	 minFilter : THREE.NearestFilter,
	 magFilter : THREE.NearestFilter,
	 format : THREE.RGBAFormat
	 });

	 var ssao = new THREE.ShaderPass(THREE.SSAOShader);
	 ssao.uniforms['tDepth'].value = depthTarget;
	 ssao.uniforms['size'].value.set(laneAssist.fensterBreite, laneAssist.fensterHoehe);
	 ssao.uniforms['cameraNear'].value = kameraPerspektiv.near;
	 ssao.uniforms['cameraFar'].value = kameraPerspektiv.far;
	 ssao.renderToScreen = false;

	var parameters = {
		anisotropy : 32,
		minFilter : THREE.LinearFilter,
		magFilter : THREE.LinearFilter,
		format : THREE.RGBAFormat,
		stencilBuffer : false
	};
	var renderTarget = new THREE.WebGLRenderTarget(laneAssist.fensterBreite, laneAssist.fensterHoehe, parameters);

	laneAssist.composer = new THREE.EffectComposer(laneAssist.renderer, renderTarget);
	laneAssist.composer.setSize(laneAssist.fensterBreite, laneAssist.fensterHoehe);
	
	
	laneAssist.composer.addPass(renderPass);
	laneAssist.composer.addPass(ssao);
	// laneAssist.composer.addPass(focusShader);
	laneAssist.composer.addPass(fxaa);
	//laneAssist.composer.addPass(effectvignette);
	laneAssist.composer.addPass(effectcopy);
}